package hibernate.clientAccount;

import java.util.*;

public class ClientVIPInfo {
	
	public static class Level{
		
		private String name;
		
		private Level(String name){
			this.name=name;
		}
		
		public String toString(){
			return name;
		}
		
		private static Level normal=new Level("NORMAL");
		private static Level advanced=new Level("ADVANCED");
		private static Level most=new Level("MOSTDISTINGUISHED");
		
		public static Level getInstance(String s){
			if(s=="NORMAL")
				return normal;
			else if(s=="ADVANCED")
				return advanced;
			else if(s=="MOSTDISTINGUISHED")
				return most;
			else 
				throw new java.lang.IllegalArgumentException("no this leval");
		}
		
		//for debug only
		public static Level getRandomLevel(){
			int i=new Random().nextInt(3);
			switch(i){
			case 0:
				return normal;
			case 1:
				return advanced;
			default:
				return most;
			}
		}
	}
	
	private String passwordQuestion=new String();
	private String passwordQuestionAnswer=new String();
	private String username=new String();
	private String password=new String();
	private Level vipLevel=Level.normal;
	private RebateInfo rebateInfo;
	private Long id;
	private VIPClient client;
	
	public Level getConcreteLevel(){
		return vipLevel;
	}
	
	public VIPClient getClient(){return client;}
	
	public void setClient(VIPClient client){this.client=client;}
	
	public void setPasswordQuestion(String question){
		passwordQuestion=question;
	}
	
	public String getPasswordQuestion(){
		return passwordQuestion;
	}
	
	public void setPasswordQuestionAnswer(String answer){
		passwordQuestionAnswer=answer;
	}
	
	public String getPasswordQuestionAnswer(){
		return passwordQuestionAnswer;
	}
	
	public void setUsername(String userName){
		username=userName;
	}
	
	public String getUsername(){
		return username;
	}
	
	public void setPassword(String password){
		this.password=password;
	}
	
	public String getPassword(){
		return password;
	}
	
	public void setVipLevel(String level){
		vipLevel=Level.getInstance(level);
	}
	
	public String getVipLevel(){
		return vipLevel.toString();
	}
	
	public void setRebateInfo(RebateInfo rebate){
		rebateInfo=rebate;
	}
	
	public RebateInfo getRebateInfo(){
		return rebateInfo;
	}
	
	public void setId(Long id){
		this.id=id;
	}
	
	public Long getId(){
		return id;
	}
	
	public boolean equals(Object obj){
		if(!(obj instanceof ClientVIPInfo))
			return false;
		else return this.id.equals(((ClientVIPInfo)obj).id);
	}
	
	public String toString(){
		return "vip "+client.toString();
	}
}
